package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.PaymentPlanDao;
import cn.gson.springboot.model.mapper.PaymentPlanMapper;
import cn.gson.springboot.model.pojos.PaymentPlan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PaymentPlanService {
    @Autowired
    PaymentPlanMapper payPlanMapper;
    @Autowired
    PaymentPlanDao payPlanDao;

    public List<PaymentPlan> selectPaymentPlan(Integer type,String payDate){
        return payPlanMapper.selectPaymentPlan(type,payDate);
    }

    public List<PaymentPlan> selectPaymentPlanByPurId(Integer purId){
        return payPlanMapper.selectPaymentPlanByPurId(purId);
    }

    public PaymentPlan selectPaymentPlanById(Integer payId){
        return payPlanMapper.selectPaymentPlanById(payId);
    }

    public List<PaymentPlan> selectPaymentPlanPastFutureThirty(){
        return payPlanMapper.selectPaymentPlanPastFutureThirty();
    }

    @Transactional(transactionManager = "transactionManager")
    public void savePaymentPlan(PaymentPlan pay){
        payPlanDao.save(pay);
    }

    @Transactional(transactionManager = "transactionManager")
    public void deletePaymentPlan(Integer payId){
        payPlanDao.deleteById(payId);
    }
}
